/****************************************************************************
 *
 * Copyright (C) 2003-2010 Los Alamos National Security, LLC
 *                         Packet Analytics Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2 as
 * published by the Free Software Foundation.  You may not use, modify or
 * distribute this program under any other version of the GNU General
 * Public License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 ****************************************************************************/
package nfse.dataset.squid;

import nfse.NetFSE;
import nfse.NetFSERecord;
import nfse.NetFSEUtil;
import nfse.gui.record.FlexRecord;


public class SquidRecord extends NetFSERecord {

    public static final int EXPECTED_TOKENS = 11;

    public String httpMethod = "";

    public String url = "";

    public String mimeType = "";

    public String clientInfo = "";

    public String dstHost = "";

    public long dstIP = -1;

    public int duration = -1;

    public int httpStatus = -1;

    public long dstBytes = 0;

    public String squidResult = "";

    @Override
    public boolean isSyslog() {
        return false;
    }

    /*******
     * There may be data in the records that needs to be hex-encoded when stored
     * in PostgreSQL. Store as hex instead of raw.
     */
    @Override
    public boolean hasBinary() {
        return true;
    }

 

    /***************************************************************************
     * The base Net/FSE class does not have a destination IP address value so
     * this stub method returns -1, an invalid IP address. Event types with a
     * destination IP address must override this method and setDstIP() as well.
     * 
     * @return -1 (stub method)
     */
    @Override
    public long getDstIP() {
        return this.dstIP;
    }

    /***************************************************************************
     * This method performs no operation by default. It should be overridden by
     * event type implementations with destination IP addresses and should set
     * the values of dstIP and dstAddr.
     * 
     */
    public void setDstIP(long dstIP) {
        this.dstIP = dstIP;
    }

    public String getDstHost() {
        String temp = null;
        if (this.getDstIP() != -1)
            temp = this.getDstAddr();
        else
            temp = this.dstHost;
        return temp;
    }

    @Override
    public int getDstPort() {
        return -1;
    }
    
    @Override
    public int[] getIndexedFields() {
        int[] temp = { NetFSE.FIELD_START_TS, NetFSE.FIELD_SRC_IP };
        return temp;
    }
    
    
}
